-
Notifications
You must be signed in to change notification settings - Fork 30
Validate hostname in cloud-init settings #543
Validate hostname in cloud-init settings #543
Conversation
Pull Request Test Coverage Report for Build 2270
💛 - Coveralls |
@@ -51,6 +52,7 @@ const validateResolver = { | |||
[IMAGE_URL_KEY]: asVmSettingsValidator(validateURL), | |||
[PROVIDER_KEY]: validateProviderDropdown, | |||
[MEMORY_KEY]: asVmSettingsValidator(validateMemory), | |||
[HOST_NAME_KEY]: asVmSettingsValidator(validateVmLikeEntityName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think host name should have the same validation as VM name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I'll create a separate function for it. I think for the moment all that's needed is validateDNS1123SubdomainValue, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y I guess, that should be enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
95ba78f
to
b00ad03
Compare
src/utils/validations.js
Outdated
@@ -123,6 +123,11 @@ export const validateVmLikeEntityName = (value, vmSettings, props) => { | |||
); | |||
}; | |||
|
|||
export const validateCloudInitHostName = value => { | |||
const dnsValidation = validateDNS1123SubdomainValue(value); | |||
return dnsValidation && dnsValidation.type === VALIDATION_ERROR_TYPE ? dnsValidation : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we have to check for the error_type here, because all the errors will be error type or none in this case. Nevertheless I do think we should check for empty error here, because the host name can be empty if I am not mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're correct. Done!
b00ad03
to
74053ff
Compare
src/utils/validations.js
Outdated
@@ -123,6 +123,11 @@ export const validateVmLikeEntityName = (value, vmSettings, props) => { | |||
); | |||
}; | |||
|
|||
export const validateCloudInitHostName = value => { | |||
const dnsValidation = validateDNS1123SubdomainValue(value); | |||
return dnsValidation && dnsValidation.type !== EMPTY_ERROR ? dnsValidation : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit differently
return dnsValidation && dnsValidation.type !== EMPTY_ERROR ? dnsValidation : null; | |
return dnsValidation && dnsValidation.isEmptyError ? null : dnsValidation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks much cleaner, thanks. =) I've updated the commit.
74053ff
to
3a97559
Compare
This PR adds hostname validation to the cloud-init settings section of the create VM/template wizard.
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1648321